package com.campus.course.controller;

import com.campus.common.result.Result;
import com.campus.course.dto.vo.CourseStudentsListVO;
import com.campus.course.service.ICourseRecordsService;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/courseSchedule")
@Tag(name = "课程选课服务")
public class CourseRecordsController {

    @Autowired
    private ICourseRecordsService courseRecordsService;

    @ApiOperation(value = "学生选课")
    @GetMapping("/choose-course/{courseId}")
    public Result stuChooseCourse (@PathVariable("courseId") int courseId) {
       return courseRecordsService.stuChooseCourse(courseId);
    }

    @ApiOperation(value = "学生退课")
    @GetMapping("/cancel-course/{courseId}")
    public Result stuCancelCourse (@PathVariable("courseId") int courseId) {
        return courseRecordsService.stuCancelCourse(courseId);
    }

    @ApiOperation(value = "获取某个课程的学生名单")
    @GetMapping("/stu-list")
    public Result<List<CourseStudentsListVO>> courseStudentList (@RequestParam("courseId") Integer courseId) {
        List<CourseStudentsListVO> list = courseRecordsService.courseStudentList(courseId);
        return Result.success(list);
    }

}
